package com.hua.designpattern.behavioral.observer.subscriber;

public class TestSubscriber {

	public static void main(String[] args) {
		SubscriberAbstract subscriber1 = new Subscriberoncrete1();
		SubscriberAbstract subscriber2 = new Subscriberoncrete2();

		PublisherAbstract publisher1 = new PublisherConcrete1();
		PublisherAbstract publisher2 = new PublisherConcrete2();

		publisher1.addSubscriber(subscriber1);
		subscriber2.addPublisher(publisher1);
		publisher1.setMessage("publisher1 send message!!");
		System.out.println("--------------");
		publisher2.addSubscriber(subscriber1);
		publisher2.addSubscriber(subscriber2);
		publisher2.setMessage("publisher2 send message");
		System.out.println("--------------");
		subscriber2.removePublisher(publisher2);
		publisher2.setMessage("publisher2 send message");

	}

}
